﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class 爆炸伤害 : MonoBehaviour
{
    // 防止重复
    ISet<int> 游戏对象集合 = new HashSet<int>();


    void OnTriggerEnter(Collider other)
    {
        if(游戏对象集合 == null)
        {
            游戏对象集合 = new HashSet<int>();
        }

        Debug.Log("被攻击对象哈希：" + other.gameObject.GetHashCode());

        if (游戏对象集合.Contains(other.gameObject.GetHashCode()))
        {
            return;
        }

        游戏对象集合.Add(other.gameObject.GetHashCode());

        if (other.tag == "坦克")
        {
            Debug.Log("打击坦克");
            other.SendMessage("受到打击", new object[] { gameObject.transform,this });
        }
    }

    void OnDestroy()
    {
        游戏对象集合 = null;
    }
}
